/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.curso.dao.serializables;

import com.curso.model.User;
import java.io.Serializable;
import java.util.List;

/**
 *
 * @author Administrador
 */
public class UserDaoSer extends GenericDaoSer<User, Serializable> {
    
    
    public User save(User user){
        user.setId(System.currentTimeMillis());
        return this.persist(user);
    }

    @Override
    public List<User> getAll() {
        return getAll(User.class);
    }

   
    public Boolean removeUser(User t) {
        return this.remove(t);
    }

   public User getUser(String username, String pass){
      List<User> users= getAll(User.class);
      User user = null;
      for(User u : users){
        if(username.equals(u.getUsername())
            &&  pass.equals(u.getPassword())){
           user = u;
        }
      }


      return user;
   }

    

   
}
